<template>
  <div>
    <el-backtop :right="100" :bottom="200" :visibility-height="10" />
    <!-- 搜索 -->
    <el-space wrap style="margin-bottom:10px">
      <span>角色名称 :</span>
      <el-input v-model="name" placeholder="请输入......" clearable />
      <span>描述信息 :</span>
      <el-input v-model="desc" clearable />
      <el-button type="primary" @click="listData">查找</el-button>
    </el-space>
    <!-- 列表 -->
    <el-table :data="tableData" style="width: 80%" border>
      <el-table-column prop="name" label="角色名称" align="center" />
      <el-table-column prop="desc" label="说明" align="center" />
      <el-table-column align="left" label="操作">
        <template #default="scope">
          <el-button size="small" type="primary" @click="handleEdit(scope.$index, scope.row)">修改</el-button>
          <el-button
            size="small"
            type="primary"
            @click="handlePermission(scope.$index, scope.row)"
          >授权</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 修改弹框 -->
    <el-dialog v-model="dialogFormVisible" title="修改信息">
      <el-form :model="form">
        <el-form-item label="角色名称 :">
          <el-input v-model="form.name" autocomplete="off" />
        </el-form-item>
        <el-form-item label="描述信息 :">
          <el-input v-model="form.desc" autocomplete="off" />
        </el-form-item>
      </el-form>
      <template #footer>
        <span class="dialog-footer">
          <el-button type="primary" @click="subMit">修改</el-button>
        </span>
      </template>
    </el-dialog>
    <!-- 分页 -->
    <dome v-bind="domes" @limits="limits" @pages="pages" />
  </div>
</template>
<script>
import {post} from "@/util/http";
import dome from "../../../components/Dome.vue";
// import { Search, Edit } from "@element-plus/icons-vue";
import { ElMessage } from "element-plus";
export default {
  components:{
    dome
  },
  data() {
    return {
      name: "", //搜索
      desc: "", //搜索
      tableData: [], //列表
      dialogFormVisible: false, //布尔值
      // 分页
      domes: {
        limit: 10,
        page: 1,
        total: 10,
      },
    };
  },
  created() {
    this.listData();
  },
  methods: {
    listData(){
          let data = {
        _gp: "admin.role",
        _mt: "list",
        roleId : e.id,
      };
      post(data)
        .then((res) => {
          if (200 == res.data.errno) {
            this.tableData = res.data.data.items
            this.domes.total = res.data.data.total
            ElMessage.success("请求成功");
            console.log(res,"授权成功");
          } else {
            ElMessage.warning(res.data.errmsg);
          }
        })
        .catch((err) => {
          ElMessage.error(err.data.errmsg);
        });
    },
    limits(e) {
      this.domes.limit = e;
      this.listData();
    },
    pages(e) {
      this.domes.page = e;
      this.listData();
    },

  },
};
</script>